package leetcode.offer_two_special.array;

/**
 * @author mazouri
 * @create 2021-09-05 9:33
 */
public class _09_numSubarrayProductLessThanK {
    public int numSubarrayProductLessThanK(int[] nums, int k) {
        int product = 1;
        int left = 0;
        int count = 0;

        for (int right = 0; right < nums.length; right++) {
            product *= nums[right];

            while (left <= right && product >= k) {
                product /= nums[left++];
            }

            count += right >= left ? right - left + 1 : 0;
        }
        return count;
    }

    public static void main(String[] args) {
        new _09_numSubarrayProductLessThanK().numSubarrayProductLessThanK(new int[2], 2);
    }
}
